package org.example.spring_book.config;

import org.example.spring_book.interceptor.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.Arrays;
import java.util.List;

/**
 * @ClassName WebConfig
 * @Description TODO
 * @Author wangxiaodong
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {
    private List<String> excludePath= Arrays.asList(
            "/user/login",
            "/**/**.html",
            "/css/**",
            "/js/**",
            "/pic/**"
    );
    @Autowired
    private LoginInterceptor loginInterceptor;
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //  /**表示让所有路径都生效
        registry.addInterceptor(loginInterceptor)
                .addPathPatterns("/**")
                .excludePathPatterns(excludePath);
    }
}
